using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Reflection;
using System.Text;
using log4net;
using log4net.Repository.Hierarchy;

namespace SharePointSearchBench.Library.Logging
{
    /// <summary>
    /// Used for writing information messages to a log.
    /// </summary>
    public class DisposableInfoLogWriter : IDisposableLogWriter
    {
        /// <summary>
        /// Creates a new instance of the class.
        /// </summary>
        public DisposableInfoLogWriter()
        {
            InfoLogWriter.WriteMessageInternal("");   
        }

        /// <summary>
        /// Creates a new instance of the class.
        /// </summary>
        /// <param name="message"></param>
        public DisposableInfoLogWriter(string message)
        {
            InfoLogWriter.WriteMessageInternal(string.Format("BEGIN: {0}", message));
        }

        /// <summary>
        /// Writes an information message to a log.
        /// </summary>
        /// <param name="message"></param>
        public void WriteMessage(string message)
        {
            InfoLogWriter.WriteMessageInternal(message);
        }

        /// <summary>
        /// Disposes the object.
        /// </summary>
        public void Dispose()
        {
            InfoLogWriter.WriteMessageInternal("END");
        }
    }
}
